package ar.unq.edu.agenda.domain;

import java.util.Date;

import org.uqbar.commons.model.Entity;

import ar.unq.edu.agenda.exceptions.InvalidParameterException;
import ar.unq.edu.agenda.utils.Validator;

/**
 * 
 * @author nicolas
 *
 */
public class Contact extends Entity{

	private static final long serialVersionUID = 1L;
	protected String name = "";
	protected String lastName = "";
	protected String phone = "";
	protected String email = "";
	protected Date birthDate;
	protected String comments = "";
	protected City city = new City();
	
	public static final String NAME = "name";
	public static final String LASTNAME="lastName";
	public static final String PHONE="phone";
	public static final String EMAIL="email";
	public static final String BIRTHDATE="birthDate";
	public static final String COMMENTS="comments";
	public static final String CITY="city";	
	
	public Contact()
	{

	}
	
	public Contact(String name, String lastName, String phone, String email, Date birthDate, String comments, City city)
	{
		this.setName(name);
		this.setLastName(lastName);
		this.setPhone(phone);
		this.setEmail(email);
		this.setBirthDate(birthDate);
		this.setComments(comments);
		this.setCity(city);
	}
	
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		if(Validator.isOnlyLetters(name))
			this.name = name;
		else
			throw new InvalidParameterException("El valor de " + name + " no es válido como nombre del Contacto");
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public void setLastName(String lastName) {
		if(Validator.isOnlyLetters(lastName))
			this.lastName = lastName;
		else
			throw new InvalidParameterException("El valor de " + lastName + " no es válido como apellido del Contacto");
		
	}
	
	public String getPhone() {
		return phone;
	}
	
	public void setPhone(String phone) {
		if(Validator.isOnlyNumbers(phone))
			this.phone = phone;
		else
			throw new InvalidParameterException("El valor de " + phone + " no es válido como teléfono del Contacto");
		
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		
		if(Validator.isValidEmail(email))
			this.email = email;
		else
			throw new InvalidParameterException("El valor de " + email + " no es válido como email del Contacto");

	}
	
	public Date getBirthDate() {
		return birthDate;
	}
	
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
	
	public String getComments() {
		return comments;
	}
	
	public void setComments(String comments) {
		this.comments = comments;
	}
	
	public City getCity() {
		return city;
	}
	
	public void setCity(City city) {
			this.city = city;
		
	}
	
	
}
